import { createPopupSlot } from '@/services/popupSlot'

export const popupSlot = createPopupSlot()

export const getSearchFieldName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 1:
        return '运单号'
      case 2:
        return '渠道单号'
      case 3:
        return 'FBA ID'
      case 4:
        return '柜号'
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [1, 2, 3, 4] },
)

export const getShipTrackStatusName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 1:
        return '不同步' as const
      case 2:
        return '同步成功' as const
      case 3:
        return '同步失败' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [1, 2, 3] },
)

export const getTabIdName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 0:
        return '全部' as const
      case 11:
        return '待处理' as const
      case 12:
        return '待发货' as const
      case 13:
        return '待离港' as const
      case 14:
        return '运输中' as const
      case 15:
        return '待提取' as const
      case 16:
        return '中转中' as const
      case 17:
        return '派送中' as const
      case 18:
        return '已签收' as const
      case 19:
        return '已取消' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [0, 11, 12, 13, 14, 15, 16, 17, 18, 19] },
)

export const getWaybillStatusName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 11:
        return '待处理' as const
      case 12:
        return '待发货' as const
      case 13:
        return '待离港' as const
      case 14:
        return '运输中' as const
      case 15:
        return '待提取' as const
      case 16:
        return '中转中' as const
      case 17:
        return '派送中' as const
      case 18:
        return '已签收' as const
      case 19:
        return '已取消' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [11, 12, 13, 14, 15, 16, 17, 18, 19] },
  {
    colorList: {
      11: '#fa541c',
      12: '#fa8c16',
      13: '#a0d911',
      14: '#faad14',
      15: '#fadb14',
      16: '#52c41a',
      17: '#13c2c2',
      18: '#1677ff',
      19: '#bfbfbf',
    },
  },
)

export const getNextUpdateTimeRemindDesc = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 1:
        return '逾期' as const
      case 2:
        return '今天更新' as const
      case 3:
        return '未设置更新时间' as const
      case 4:
        return '更新时间晚于今天' as const
      case 5:
        return '已签收运单，不再需要更新时间提醒' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [1, 2, 3, 4, 5] },
  {
    colorList: {
      1: '#f5222d',
      2: '#52c41a',
      3: '#fadb14',
      4: '#bfbfbf',
      5: '#ffffff', // TODO: 显示白色icon？？？？
    },
  },
)

export const getShipTrackStatusDesc = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 1:
        return '不同步' as const
      case 2:
        return '更新成功' as const
      case 3:
        return '更新失败' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [1, 2, 3] },
  {
    colorList: {
      1: '#bfbfbf',
      2: '#52c41a',
      3: '#f5222d',
    },
  },
)

export const getLogisticsProductServiceLevelName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 1:
        return 'Standard' as const
      case 2:
        return 'Fast' as const
      case 3:
        return 'Expedited' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [1, 2, 3] },
)

export const getStaffTypeName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 1:
        return '业务人员' as const
      case 2:
        return '港后跟单' as const
      case 3:
        return '港前操作' as const
      case 4:
        return '港后操作' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [1, 2, 3, 4] },
)

export const getTailLineName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 1:
        return '快递' as const
      case 2:
        return '卡车' as const
      case 3:
        return 'Amazon Freight' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [1, 2, 3] },
)

export const getTransportationTypeName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 1:
        return '海运' as const
      case 2:
        return '空运' as const
      case 3:
        return '卡车' as const
      case 4:
        return '铁路' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [1, 2, 3, 4] },
)
